package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import org.springframework.stereotype.Service;

import com.iwhalecloud.bss.kite.common.constant.ErrorConsts;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;

import com.ztesoft.bss.common.util.SpringUtil;

/**
 * 平台服务级别处理器
 */
@Service
public class PlatformServiceLevelAttrHandler extends AbstractAttrHandler<KiteProdInst, AttrData> {

    @Override
    public void before(KiteAttr attr, KiteProdInst inst, String value, AttrData data) {
        if (!"100006417".equals(value)) {
            return;
        }
        IQuerySceneInstService querySceneInstService = SpringUtil.getBean(IQuerySceneInstService.class);
        KiteAttr tempAttr = querySceneInstService.getCommonAttr(data.getSceneInstId(), "10004282");
        if (tempAttr != null && "T".equals(tempAttr.getValue())) {
            ErrorConsts.BUSI_COMMON_ERROR.throwOut("附加产品选择是可付费套包，平台服务级别的高级平台不能选择");

        }
    }

    @Override
    public void set(KiteAttr attr, KiteProdInst inst, String value, AttrData data) {
        super.set(attr, inst, value, data);
    }
}
